//
//  BCSvipMenberHeaderCollectionCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/21.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCSvipMenberHeaderCollectionCell.h"

#import "BCUserSvipDataShares.h"

@interface BCSvipMenberHeaderCollectionCell ()

@property (nonatomic, strong) UIImageView *selectIV;

/**
 *menberIV
 */
@property (nonatomic, strong) UIImageView *menberIV;

/**
 *menberLabel
 */
@property (nonatomic, strong) QMUILabel *menberLabel;

@end

@implementation BCSvipMenberHeaderCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}
- (void)setupSubviews {
    self.selectIV = [UIImageView new];
    [self.contentView addSubview:self.selectIV];
    [self.selectIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.contentView);
    }];
    self.selectIV.image = LOAD_IMAGE(@"svip_menber_normal");
    //
    self.menberIV = [UIImageView new];
    self.menberIV.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.menberIV];
    [self.menberIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView).offset(19.0*WidthScale);
        make.centerX.mas_equalTo(self.contentView);
        make.width.height.mas_equalTo(45.0*WidthScale);
    }];
    //
    self.menberLabel = [QMUILabel new];
    self.menberLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.menberLabel.numberOfLines = 2;
    self.menberLabel.textColor = [UIColor qmui_colorWithHexString:@"#000000"];
    self.menberLabel.adjustsFontSizeToFitWidth = true;
    self.menberLabel.minimumScaleFactor = 0.6;
    self.menberLabel.contentEdgeInsets = UIEdgeInsetsMake(2, 2, 2, 2);
    self.menberLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.menberLabel];
    [self.menberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.menberIV.mas_bottom);
        make.left.bottom.right.mas_equalTo(self.contentView);
    }];
}


- (void)setShare:(BCUserSvipDataShares *)share {//svip_menber_selected svip_menber_normal
    _share = share;
    //
    NSString *imagename = share.selectFlag?@"svip_menber_selected":@"svip_menber_normal";
    self.selectIV.image = LOAD_IMAGE(imagename);
    //
    [self.menberIV sd_setImageWithURL:[NSURL URLWithString:share.icon]];
    //
    self.menberLabel.text = share.title;
}

@end
